﻿@model IEnumerable<Article>
@(
 Ajax.Dna().Accordion()
        .Options(opts =>
        {
            opts.Icons = new AccordionOptions.HeaderIconsStyle()
            {
                HeaderCssClass = "d-accordion-icon",
                HeaderSelectedIconCssClass = "d-accordion-icon-select"
            };
            opts.AutoHeight = false;
            opts.Navigation = true;
        })
        .Name("Accordion_" + Guid.NewGuid().ToString().Substring(0, 5))
        .Sections(sections =>
        {
            foreach (var art in Model)
            {
                var article = new ArticleWrapper(art);
                if (!article.IsVisible(Context))
                {
                    continue;
                }
                var _post = article;
                var _textLen = (int)ViewData["TextLen"];
                var _postTitle = article.Title;
                var _showAuthor = (bool)ViewData["ShowAuthor"];
                var _showDate = (bool)ViewData["ShowDate"];
                _postTitle = Html.Cut(_postTitle, _textLen);
                sections.Add(_postTitle).Template(@<text>
<table style="width: 100%;">
    @if (_showAuthor || _showDate)
    {
        <tr>
            <td colspan="2">
                <i style="color: #cccccc;">
                    @if (_showAuthor)
                    {
                        @Html.Global("publishing", "Postby") @Html.UserLink(article.Author.UserName)
                    }
                    @if (_showDate)
                    {
                        @Html.Global(article.Posted)
                    }
                </i>
            </td>
        </tr>
    }
    <tr>
        <td style="vertical-align: top;">
            @if (!string.IsNullOrEmpty(_post.ImageUrl))
            { 
                <img src="@_post.ImageUrl" alt="@_post.Title" title="@_post.Title" />
            }
        </td>
        <td style="vertical-align: top;">
            @Publishing.PostSummary(_post)
        </td>
    </tr>
    <tr>
        <td colspan="2" style="text-align: right;">
            <a href="@_post.PermaLink" class="d-link">@Html.Global("RES_MORE")</a>
        </td>
    </tr>
</table>
</text>);
            }
        }).GetHtml()
)
@Html.StartupScripts()
